﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Linq;
using System.Text;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace SmartIMS.Core.Models
{
    /// <summary>
    /// Lop co ban cua Model
    /// </summary>
    public class BaseModels
    {
        /// <summary>
        /// Loi xay ra khi thao tac voi CSDL
        /// </summary>
        public string ErrorMessage { get; set; }
        /// <summary>
        /// Gia tri tra lai
        /// </summary>
        public string ValueReturn { get; set; }
        /// <summary>
        /// Tong so ban ghi
        /// </summary>
        public int TotalRecord { get; set; }

        public BaseModels()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        protected OracleConnection GetOracleConnection()
        {
            string strConnectionString;
            string strConnectionSetting = Utils.GetParameterValue("connectionSetting");
            if (strConnectionSetting == "production")
            {
                strConnectionString = "Data Source=NEWCORE_PRIMARY;User ID=back;Password=Tls_oracleBACK64_05092011;Unicode=True;Pooling=yes;Connection Lifetime=20;Max Pool Size=500;Min Pool Size=5";
            }
            else
            {
                strConnectionString = ConfigurationManager.ConnectionStrings["Oracle"].ToString();
            }
            return new OracleConnection(strConnectionString);
        }
        

    }
}
